<?php
if (!defined('admin')) {
    exit();
}
if (get_admin_level() < 2) adminmsg('', "您没有操作的权限");

admin_page_start("数据库备份");
?>
    <h3>数据库备份</h3>

    <div class="panel-body">
        <table class="table table-responsive table-bordered">
            <tr>
                <th>#</th>
                <th>文件</th>
                <th>时间</th>
                <th>操作</th>
            </tr>
            <?php
            $sql_list = ls(DBDir . 'backup/', "*.sql");
            if ($sql_list) {
                $i = 0;
                foreach ($sql_list as $item) {
                    if (is_backfile($item)) {
                        continue;
                    }
                    $i++;
                    ?>
                    <tr>
                        <td><?= $i ?></td>
                        <td><?= file_name($item) ?></td>
                        <td><?= humanizer_datetime(file_modifitime($item)) ?></td>
                        <td><a href="?do=backup_del&file=<?= file_name($item) ?>" class="btn btn-danger btn-xs" onclick="return confirm('确定要删除此备份文件？删除后将无法还原')">删除</a></td>
                    </tr>
                    <?php
                }
            } else {
                ?>
                <tr>
                    <td colspan="4" class="text-center">暂无备份</td>
                </tr>
            <?php } ?>
        </table>
    </div>
    <div class="text-center">
        <a class="btn btn-primary" href="?do=backup_bak" onclick="return confirm('立刻进行数据库备份吗？如果数据库比较庞大，备份操作将影响用户访问！建议在访问人数不多时进行')">立即备份</a>
    </div>
<?php
admin_page_end();
